const ua = navigator.userAgent.toLowerCase();
const detectZoom = () => {
  let ratio = 1;
  try {
    let screen = window.screen
    // console.log(screen, 'screen')
    // console.log('设备像素比', window.devicePixelRatio)
    if (window.devicePixelRatio !== undefined) {
      // 临时方案处理macbook视网膜屏基础像素比问题
      ratio = ua.includes('mac os') ? ((1920 / window.screen.width) * (window.devicePixelRatio / 2)) : window.devicePixelRatio;
    } else if (~ua.indexOf('msie')) {
      if (screen.deviceXDPI && screen.logicalXDPI) {
        ratio = screen.deviceXDPI / screen.logicalXDPI;
      }
    } else if (window.outerWidth !== undefined && window.innerWidth !== undefined) {
      ratio = window.outerWidth / window.innerWidth;
    }
    if (ratio) {
      ratio = Math.round(ratio * 100);
    }
  } catch (error) {
    console.error('系统缩放比例获取失败')
  }
  return ratio;
}
// 系统缩放比例
const m = Number(detectZoom() || 1);
document.body.style['zoom'] = detectZoom() / m;
document.body.style.setProperty("--zoom", String(detectZoom() / m))
